<?php
function reCAPTCHA_onLoad($db) {
	if ($GLOBALS['authNamespace']->admin && isset($_REQUEST['recapsubmit'])) {
		$db->delete('recaptcha');
		$db->insert('recaptcha', array('publickey' => $_REQUEST['publickey'], 'privatekey' => $_REQUEST['privatekey']));
		header("Location: " . $_SERVER['PHP_SELF'] . '?mod=contact&action=manage');
		exit;
	}
}

function reCAPTCHA_adminMenu($translate) {
	$stack = array();
	$stack[] = $translate->_("reCAPTCHA Config");
	$stack['action=manage'] = $translate->_("Key Config");
	return $stack;
}

function reCAPTCHA_main($db, &$view, $translate) {
	if ($GLOBALS['authNamespace']->admin && isset($_GET['action']) && $_GET['action'] == 'manage') {
		$data = $db->fetchRow("SELECT * FROM `recaptcha`");
		$view->assign('data', $data);
		$view->display('file:../../../modules/reCAPTCHA/manage.tpl');
	}
}
?>